package com.h3c.nem.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.h3c.nem.entity.OfferSocialsecurityaddress;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * (OfferSocialsecurityaddress)表数据库访问层
 *
 * @author makejava
 * @since 2022-06-22 19:20:51
 */
public interface OfferSocialsecurityaddressMapper extends BaseMapper<OfferSocialsecurityaddress> {

    @Select("SELECT offerid FROM Offer_SocialSecurityAddress GROUP BY offerid HAVING COUNT(1)>1")
    public List<String> queryRepeatSocialSecurityAddress();

    @Update(" delete from Offer_SocialSecurityAddress " +
            " where id != (SELECT a.id FROM (SELECT id FROM Offer_SocialSecurityAddress where offerid=#{offerId}  order by createTime desc limit 1) AS a)" +
            " and offerid = #{offerId} ")
    public Integer deleteRepeatSocialSecurityAddress(@Param("offerId")String offerId);

}

